//
//  NoteSettingViewController.m
//  SIPphone
//
//  Created by wrt on 13-11-13.
//  Copyright (c) 2013年 wrtsoft. All rights reserved.
//

#import "NoteSettingViewController.h"

@interface NoteSettingViewController ()

@end

@implementation NoteSettingViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        self.title = NSLocalizedString(@"log Settings", @"日志配置 Log Settings");
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *isOpenNote = [[NSString alloc] init];
    isOpenNote = [defaults objectForKey:@"SAVEISOPENNOTE"];
    if (isOpenNote.length > 0)
    {
        if ([isOpenNote isEqualToString:@"YES"])
        {
            [self.noteSwitch setOn:YES];
        }
        else if ([isOpenNote isEqualToString:@"NO"])
        {
            [self.noteSwitch setOn:NO];
        }
    }
}

- (IBAction)openNoteSwitch:(id)sender
{
    UISwitch *switchControl = (UISwitch *)sender;
    SIPInterface *interface = [SIPInterface shareSIPInterface];
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    BOOL isOpenSound = switchControl.on;
    if (isOpenSound == YES)
    {
        [interface isOpenNote:YES];
        [defaults setObject:@"YES" forKey:@"SAVEISOPENNOTE"];
    }
    else
    {
        [interface isOpenNote:NO];
        [defaults setObject:@"NO" forKey:@"SAVEISOPENNOTE"];
    }
    [defaults synchronize];
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
